<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>后盾人</title>
  </head>
  <body>
    <main>
      后盾人不断分享视频教程，后盾人网址是 houdunren.com后盾人后盾人
    </main>
  </body>
  <script>
    //exec match
    let reg = /后盾人/g;
    const main = document.querySelector("body main");
    let count = 0;
    while ((res = reg.exec(main.innerHTML))) {
      count++;
    }
    console.log(count);
    // console.log(main.innerHTML.match(reg));
    // console.log(reg.exec(main.innerHTML));
    // console.log(reg.lastIndex);
    // console.log(reg.exec(main.innerHTML));
    // console.log(reg.lastIndex);
    // console.log(reg.exec(main.innerHTML));
    // console.log(reg.lastIndex);
  </script>
</html>
